Skip to content

RERUM Server NPM Package Updates#220

Merged
thehabes merged 16 commits intomainfrom
10-2-25-packages
Oct 15, 2025
Merged

RERUM Server NPM Package Updates#220
thehabes merged 16 commits intomainfrom
10-2-25-packages

Conversation

@thehabes
Copy link
Copy Markdown
Member

@thehabes thehabes commented Oct 2, 2025

Includes updated exists tests.

@thehabes thehabes self-assigned this Oct 3, 2025
@thehabes thehabes changed the title NPM Package Updates RERUM Server NPM Package Updates Oct 6, 2025
@thehabes thehabes marked this pull request as ready for review October 6, 2025 20:09
@thehabes thehabes requested a review from cubap as a code owner October 6, 2025 20:09
@thehabes thehabes requested a review from Copilot October 6, 2025 20:10
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

Upgrades core dependencies (notably Express to v5) and rewrites route existence tests to inspect the Express routing table instead of making HTTP requests. Also updates Node.js engine requirement and adds a few repository file presence checks in tests.

  • Upgrade dependencies (express 5.x, jest 30.x, mongodb 6.20.x, etc.) and Node engine to >=22.20.0
  • Replace regex-string scanning in route tests with a routeExists helper, and add checks for repo files
  • Modify maintenance middleware route in app.js

Reviewed Changes

Copilot reviewed 3 out of 4 changed files in this pull request and generated 6 comments.

File Description
package.json Bumps Node engine and several dependencies; removes @jest-mock/express; updates jest and supertest.
app.js Changes the catch-all maintenance route path.
tests/routes_mounted.test.js Replaces route detection logic with a helper function and adds file presence assertions.

Comment thread app.js
* This is without middleware
*/
app.all('*', (req, res, next) => {
app.all('*_', (req, res, next) => {
Copy link

Copilot AI Oct 6, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The route path '_' will not match all requests; it will only match a literal path ending with an underscore. To preserve the intended catch-all behavior for maintenance gating, restore the path to '' so all routes are intercepted.

Suggested change
app.all('*_', (req, res, next) => {
app.all('*', (req, res, next) => {

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NOT ANYMORE BECAUSE EXPRESS 5

import fs from "fs"

let app_stack = app._router.stack
let app_stack = app.router.stack
Copy link

Copilot AI Oct 6, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Express exposes the router stack on app._router, not app.router. app.router is undefined in Express 4 and 5, which will cause a TypeError when accessing .stack. Use app._router.stack instead.

Suggested change
let app_stack = app.router.stack
let app_stack = app._router.stack

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NOT ANYMORE BECAUSE EXPRESS 5

Comment on lines +23 to +41
function routeExists(stack, testPath) {
for (const layer of stack) {
// Check if layer has matchers (Express 5)
if (layer.matchers && layer.matchers.length > 0) {
const matcher = layer.matchers[0]
const match = matcher(testPath)
if (match && match.path) {
return true
}
}
// Also check route.path directly if it exists
if (layer.route && layer.route.path) {
if (layer.route.path === testPath || layer.route.path.includes(testPath)) {
return true
}
}
}
return false
}
Copy link

Copilot AI Oct 6, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mount layers like '/v1' and '/client' are represented as Layer objects without layer.route, so this helper will miss mounted prefixes. Additionally, route.path can be an array. Add a fallback using layer.regexp.test(testPath) and handle array route paths to correctly detect mounts and multi-path routes.

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NOT ANYMORE BECAUSE EXPRESS 5

Comment thread __tests__/routes_mounted.test.js Outdated
Comment thread package.json Outdated
"dependencies": {
"@jest/globals": "^29.7.0",
"cookie-parser": "~1.4.4",
"@jest/globals": "^30.2.0",
Copy link

Copilot AI Oct 6, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jest/globals is only used in tests and should be listed under devDependencies instead of dependencies to avoid adding it to the production install footprint.

Copilot uses AI. Check for mistakes.
Comment thread package.json
"repository": "github:CenterForDigitalHumanities/rerum_server_nodejs",
"engines": {
"node": ">=22.12.0"
"node": ">=22.20.0"
Copy link

Copilot AI Oct 6, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Node.js engine requirement has changed; please ensure the project's setup docs and any CI configuration are updated to reflect '>=22.20.0' so contributors and pipelines use a compatible version.

Copilot uses AI. Check for mistakes.
thehabes and others added 4 commits October 6, 2025 15:14
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@thehabes thehabes merged commit 3c32a20 into main Oct 15, 2025
6 checks passed
@thehabes thehabes deleted the 10-2-25-packages branch November 6, 2025 21:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Establish Tests That Check if All Expected Routes are Registered

3 participants